export const vaildatorRules = vm => {
  const rules = {
    code: [
      {
        required: true,
        trigger: 'change',
        message: '请选择仓库',
      },
    ],
    create_type: [
      {
        required: true,
        trigger: 'change',
        message: '请选择创建类型',
      },
    ],

    order_type: [
      {
        required: true,
        trigger: 'change',
        message: '请选择订单类型',
      },
    ],

    ship_type: [
      {
        required: true,
        trigger: 'change',
        message: '请选择运输方式',
      },
    ],
    logistics: [
      {
        required: true,
        trigger: 'change',
        message: '请输入承运商',
      },
    ],

    receiver: [
      {
        required: true,
        trigger: 'change',
        message: '请输入发件人',
      },
    ],

    address: [
      {
        required: true,
        trigger: 'change',
        message: '请输入收件地区',
      },
    ],
    detail: [
      {
        required: true,
        trigger: 'change',
        message: '请输入门牌号',
      },
    ],
    quantity: [
      {
        required: true,
        trigger: 'change',
        validator: (rule, value, callback) => {
          const list = vm.infoModel.inbound_packages_list
          let flag = false
          for (let i = 0; i <= list.length; i++) {
            if (list[i] && !list[i].quantity) {
              flag = '请输入箱子数量'
              break
            }
          }

          if (flag) {
            callback(new Error(flag))
          } else {
            callback()
          }
        },
      },
    ],
  }
  return rules
}
